package com.fhz.mvvmshopjava.api;

import androidx.lifecycle.LiveData;

import com.fhz.mvvmshopjava.data.model.LoggedInUser;
import com.fhz.mvvmshopjava.entity.Banner;
import com.fhz.mvvmshopjava.entity.Category;
import com.fhz.mvvmshopjava.entity.Goods;
import com.fhz.mvvmshopjava.entity.Order;
import com.fhz.utilsfhz.ApiResponse;

import java.util.List;

import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Part;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * 时间:2022/6/7
 *
 * @author msfeng
 * 简述: 后端接口
 */
public interface ServiceApi {

    String BASE_URL = "http://www.fenghongzhang.com:9999/";

//    @POST("user/register")
//    LiveData<>

    @POST("user/login")
    @FormUrlEncoded
    LiveData<ApiResponse<LoggedInUser>> login(@Field("nickname") String nickname,@Field("password") String password);

    //banner
    @GET("/banner/getImages")
    LiveData<ApiResponse<List<Banner>>> getBanner();

    //分类
    @GET("/category/getType")
    LiveData<ApiResponse<List<Category>>> getCategory(@Query("type") String type);

    //商品详情
    @GET("/goods/info/{id}")
    LiveData<ApiResponse<Goods>> getGoods(@Path("id") String id);

    //购物车->订单的逻辑
    @POST("/orderGoods/addOrder")
    LiveData<ApiResponse<Order>> addOrder(@Body Order order);

    //查询购物车
    @GET("/orderGoods/getAllByUser")
    LiveData<ApiResponse<List<Order>>> getAllOrderByUser(@Query("userId") Integer userId,@Query("state") Integer state);

    //更新购物车数量
    @POST("/orderGoods/updateOrderNum")
    LiveData<ApiResponse<String>> updateOrderNum(@Query("orderId") Integer orderId,@Query("num") Integer num);

}
